package com.franklin.ideaplugin.mybatisrunner.event;

import com.franklin.ideaplugin.api.event.AbstractProjectEventFactory;
import com.franklin.ideaplugin.mybatisrunner.psi.MybatisPsiElement;
import com.franklin.tool.event.IEventMulticaster;
import com.intellij.openapi.project.Project;

/**
 * @author Ye Junhui
 * @since 2024/2/20
 */
public class SqlEventFactory extends AbstractProjectEventFactory<MybatisPsiElement> {
    public SqlEventFactory(Project project) {
        super(project);
    }

    /**
     * 实例
     * @param project
     * @return
     */
    public static SqlEventFactory getInstance(Project project){
        return project.getService(SqlEventFactory.class);
    }

    /**
     * 获取广播器
     * @param mybatisPsiElement
     * @return
     */
    public static IEventMulticaster getSqlMulticaster(MybatisPsiElement mybatisPsiElement){
        return getInstance(mybatisPsiElement.getProject()).getMulticaster(mybatisPsiElement);
    }


    @Override
    protected String buildCacheKey(MybatisPsiElement mybatisPsiElement) {
        return mybatisPsiElement.buildKey();
    }
}
